#include("/front/family/_layout.html")
#@layout()
#define layoutImportcss()
    <link rel="stylesheet" href="/front/css/framework7-icons.css">
    <link rel="stylesheet" href="/front/css/input.css">
    <link rel="stylesheet" href="/front/css/grid.css">
#end
#define layoutHead()
	<title>注册</title>
#end
#define layoutHome()
            <div class="page-content login-page-content">
                <div class="login-my-screen">
                    <span class="head-portrait head-portrait-big"><img src="/front/img/user.png"></span>
                </div>
                <div class="box">
                    <form id="my-form" class="list login-form no-hairlines-md">
                        <ul>
                            <li class="item-content item-input">
                                <div class="item-media">
                                    <i class="f7-icons">person</i>
                                </div>
                                <div class="item-inner">
                                    <div class="item-input-wrap">
                                        <input name="username" type="text" placeholder="手机号" required>
                                        <span class="input-clear-button"></span>
                                    </div>
                                </div>
                            </li>
                            <li class="msg msg-verifycode"></li>
                            <li class="item-content item-input">
                                <div class="item-media">
                                    <i class="f7-icons">lock</i>
                                </div>
                                <div class="item-inner">
                                    <div class="item-input-wrap">
                                        <input name="password" type="password" placeholder="密码" required>
                                        <span class="input-clear-button"></span>
                                    </div>
                                </div>
                            </li>
                            <li class="msg msg-mobile"></li>
                            <li class="item-content item-input">
                                <div class="item-media">
                                    <i class="f7-icons">compose_fill</i>
                                </div>
                                <div class="item-inner">
                                    <div class="item-input-wrap">
                                        <input name="parent_name" type="text" placeholder="家长姓名" required>
                                        <span class="input-clear-button"></span>
                                    </div>
                                </div>
                            </li>
                            <li class="msg msg-welcomecode"></li>
                            <li class="item-content item-input">
                                <div class="item-media">
                                    <i class="f7-icons">images_fill</i>
                                </div>
                                <div class="item-inner">
                                    <div class="item-input-wrap">
                                        <input name="verifycode" type="text" placeholder="验证码" required>
                                        <span class="input-clear-button"></span>
                                    </div>
                                </div>
                                <img id="img_verify" style="height: 36px;" onclick="this.src=this.src+'?c='+Math.random();" src="" />
                            </li>
                            <li class="msg msg-password"></li>
                            <li class="item-content item-input">
                                <div class="item-media">
                                    <i class="f7-icons">compose_fill</i>
                                </div>
                                <div class="item-inner">
                                    <div class="item-input-wrap">
                                        <input name="family_code" type="text" placeholder="邀请码" required>
                                        <span class="input-clear-button"></span>
                                    </div>
                                </div>
                            </li>
                            <li class="msg msg-welcomecode"></li>
                        </ul>
                        <div class="block row">
                            <div class="col"><a class="button convert-form-to-data" href="#" id="submit">注册</a></div>
							
                        </div>
						<div class="block row">
							<div class="col" style="text-align: center;"><a class="external" href="/front/family/login" id="a_login">登录</a></div>
								
							</div>
                    </form>
                </div>
            </div>
        
#end
#define layoutImportjs()
	<script type="text/javascript" src="/front/js/form.js"></script>
#end
#define layoutScript()
<script type="text/javascript">
	
		$$('#img_verify').attr('src', '/api/verify?c='+Math.random());
	$$('#submit').on('click', function(){
	  if (validateForm('#my-form')){
		  var formData = app.form.convertToData('#my-form');
		  var url = "/front/family/register/save";
		  app.request({
		      url: url,
		      method: "POST",
		      dataType: "json", // 返回数据类型，可以是 json
		      data: formData,
		      success: function(res, status){
		          console.log(res);
		          if(res.code == 200){
		              // 请求成功，跳转首页 (动态页面)
					  alert('注册成功！请登录！');
		              window.location.href = "/front/family/login";
		          }else{
				  alert(res.msg);
				  }
		      },
		      error: function(xhr, status){
		          alert(status);
		      }
		  });
	  }
	});
</script>
#end